home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Utilities / PGP / source / pgp50i-b8a / tools / heap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-04  |  871 b   |  45 lines

  1. /*
  2.  * heap.h -- Simple priority queue.  Takes pointers to cost values
  3.  * (presumably the first field in a larger structure) and returns
  4.  * them in increasing order of cost.
  5.  *
  6.  * Copyright (C) 1997 Pretty Good Privacy, Inc.
  7.  *
  8.  * Written by Colin Plumb and Mark H. Weaver
  9.  *
  10.  * $Id: heap.h,v 1.5 1997/07/07 21:26:39 colin Exp $
  11.  */
  12.  
  13. #ifndef HEAP_H
  14. #define HEAP_H 1
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <limits.h>
  19.  
  20. typedef int HeapCost;
  21. #define COST_INFINITY INT_MAX
  22. typedef unsigned HeapIndex;
  23.  
  24. typedef struct Heap {
  25.     HeapCost    **elems;
  26.     HeapIndex    numElems, elemsAllocated;
  27. } Heap;
  28.  
  29. void HeapInit(Heap *heap, HeapIndex initSize);
  30. void HeapDestroy(Heap *heap);
  31. void HeapInsert(Heap *heap, HeapCost *newElem);
  32. HeapCost *HeapGetMin(Heap *heap);
  33. void HeapVerify(Heap *heap);
  34.  
  35.  
  36. /*
  37.  * Local Variables:
  38.  * tab-width: 4
  39.  * End:
  40.  * vi: ts=4 sw=4
  41.  * vim: si
  42.  */
  43.  
  44. #endif
  45.